package com.shy.initializer;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

public class MyInitializer implements ApplicationContextInitializer {
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        System.out.println("====== my initializer start ======");
        System.out.println("------ 打印系统参数 ------");

        ConfigurableEnvironment environment = applicationContext.getEnvironment();
        environment.getSystemProperties().forEach((k, v) -> {
            System.out.println(k + " : " + v);
        });

        System.out.println("打印环境变量");
        environment.getSystemEnvironment().forEach((k, v) -> {
            System.out.println(k + " : " + v);
        });

        environment.getPropertySources().forEach(ps -> {
            System.out.println(ps.getName() + " : " + ps.getSource());
            System.out.println(">>>>>" +ps.getSource());
        });
    }
}
